package com.pantuo.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pantuo.sys.dao.CompanyDao;
import com.pantuo.sys.pojo.Company;
import com.pantuo.sys.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CompanyServiceImpl implements CompanyService {


    @Autowired
    private CompanyDao companyDao;


    /**
     * 查询所有公司名称以及对应的id
     *
     * @return
     */
    @Override
    public List<Map<String, Object>> findAllNames() {
        QueryWrapper<Company> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "companyName_s");
        return companyDao.selectMaps(queryWrapper);
    }

    /**
     * 根据公司名称查询出公司id
     *
     * @param companyName_s
     * @return
     */
    @Override
    public Integer findIdByName(String companyName_s) {
        QueryWrapper<Company> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("companyName_s", companyName_s);
        Integer id = companyDao.selectOne(queryWrapper).getId();
        return id;
    }

}
